﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Collections;
using System.ComponentModel;
using System.Threading;
using Styx;
using Styx.Combat.CombatRoutine;
using Styx.Helpers;
using Styx.Logic;
using Styx.Logic.Combat;
using Styx.Logic.Pathing;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;
using HBPVPDruid.Misc;


namespace HBPVPDruid.Movement
{
    public static class MovementSleep
    {

        private static LocalPlayer Me { get { return ObjectManager.Me; } }
        private static bool JumpLeft = false;   // Jumpleft = true; Jumpleft = false = right

        public static void Pulse(WoWUnit Player)
        {
            if (Me.IsCasting) return;
            if (Me.Stunned) return;
            if (!Me.IsAlive) return;
            if (Player.HasAura("Insect Swarm") && Player.HasAura("Moonfire")) return;

            // Add more than strafe later
            DoRandomStrafe();
        }

        public static void CheckDistance(WoWUnit Player)
        {
            if (Player.Distance < 33) return;
            if (GetTargetPlayer.SingleTarget == false) return;

            Misc.Misc.slog("Move to {0} Distance {1}", Player.Name, Convert.ToInt32(Player.Distance));
            // Move closer to
            Navigator.MoveTo(WoWMathHelper.CalculatePointFrom(Me.Location, Player.Location, 30));

        }


        public static void DoRandomStrafe()
        {
            // Get which way to strafe,
            WoWMovement.MovementDirection WayToStrafe;  // Create Var
            WayToStrafe = WoWMovement.MovementDirection.StrafeRight; // Set to default right
            if (JumpLeft == true) WayToStrafe = WoWMovement.MovementDirection.StrafeLeft; // if left set to left

            // Ok now lets strafe, If all good throw in a jump if we want to
            WoWMovement.Move(WayToStrafe);
            //DoRandomJump();
            Thread.Sleep(200);
            WoWMovement.MoveStop();

            if (WayToStrafe == WoWMovement.MovementDirection.StrafeLeft) Misc.Misc.DebugLog("[Movement] Strafing Left");
            if (WayToStrafe == WoWMovement.MovementDirection.StrafeRight) Misc.Misc.DebugLog("[Movement] Strafing Right");

            // One lined this shit so looks neater for now.
            if (JumpLeft == true) { JumpLeft = false; } else { JumpLeft = true; }
        }




        /// <summary>
        /// will 50/50 Randomly jump
        /// </summary>
        private static void DoRandomJump()
        {
            if (ShouldIRandomJump)
            {
                Misc.Misc.DebugLog("[Movement]: Randomly Jumping");
                WoWMovement.Move(WoWMovement.MovementDirection.JumpAscend);
            }
        }

        /// <summary>
        /// Determines if it should jump or not
        /// </summary>
        private static bool ShouldIRandomJump
        {
            get
            {
                // 50/50 change of jumping seems good.
                Random num = new Random();
                int numb = num.Next(0, 3);

                if (numb == 1) return true;
                return false;
            }
        }

    }
}
